<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfRolePermissionMappings extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('role_permission_mappings', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger("roleId")->comment("角色ID");
            $table->unsignedInteger("permissionId")->comment("权限id");
            $table->unsignedInteger("createdAt")->default(0)->comment("创建时间");
            $table->unsignedInteger("updatedAt")->default(0)->comment("修改时间");
            $table->tinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除，1：已删除");

            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}role_permission_mappings` COMMENT = '角色权限表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('role_permission_mappings');
    }
}
